package com.bu.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

/**
 * @author Xueqiang Mi
 * @since 2011-3-11
 */
@PersistenceCapable(table = "Courses", identityType = IdentityType.APPLICATION)
public class Course {
	@PrimaryKey
	private String name;
	@Persistent
	private Set<Topic> topics;
	@Persistent
	private Set<Long> problems;
	@Persistent
	private Date crtDate;

	public Date getCrtDate() {
		return crtDate;
	}

	public String getName() {
		return name;
	}

	public Set<Long> getProblems() {
		if (problems == null) {
			problems = new HashSet<Long>();
		}
		return problems;
	}

	public Set<Topic> getTopics() {
		if (topics == null) {
			topics = new HashSet<Topic>();
		}
		return topics;
	}

	public void setCrtDate(Date crtDate) {
		this.crtDate = crtDate;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setProblems(Set<Long> problems) {
		this.problems = problems;
	}

	public void setTopics(Set<Topic> topics) {
		this.topics = topics;
	}

	@Override
	public String toString() {
		return "Course [name=" + name + ", problems=" + problems + ", crtDate=" + crtDate + "]";
	}
}
